<?php
use yii\bootstrap\ActiveForm;
?>
<link rel="stylesheet" href="../static/dist/css/AdminLTE.min.css" type="text/css">
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/datatables/jquery.dataTables.css" type="text/css">
<link rel="stylesheet" href="../static/css/admin.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<link rel="stylesheet" href="../static/jBox/Skins/Metro/jbox.css" type="text/css">
<link rel="stylesheet" href="../static/plugins/bootstrap-select/css/bootstrap-select.css" type="text/css">
<style>
    .ul_tree_display{
        display: none;
    }
    .tr_tree_display{
        display: none;
    }
    .dataTables_length{
        margin-top: 10px;
    }
    .dataTable>tbody>tr>td{
        vertical-align: middle;
        font-size: 0.8em;
        padding: 8px 18px;
    }
    .dataTable>thead>tr>th{
        vertical-align: middle;
        font-size: 0.8em;
    }
</style>
<div class="tabs-panel">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <!--<h3 class="box-title">Hover Data Table</h3>-->
                    用户名: <input class="depart-input" name="user_name" id="user_name" type="text" placeholder=""> &nbsp;
                    姓名: <input class="depart-input" name="name" id="name" type="text" placeholder="">
                    <button type="button" class="btn btn-primary depart-modal" id="select_button" style="width: 100px;">查询</button> &nbsp;
                    <button type="button" class="btn btn-warning depart-modal" id="reset_button" style="width: 100px;">重置</button>
                    <!--部门:<select name="dept_id" id="dept_id"></select>-->
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <button type="button" class="btn btn-success depart-modal" id="add_button" style="width: 100px;">添加</button>
                    <table id="table_list" class="display nowrap" width="100%" cellspacing="0">
                        <thead>
                        <tr>
                            <th>操作</th>
                            <th>用户ID</th>
                            <th>用户名</th>
                            <th>姓名</th>
                            <th>部门</th>
                            <th>电话</th>
                            <th>邮箱</th>
                            <th>最后登录时间</th>
                            <th>最后登录ip</th>
                            <th><?=TITLE_STATUS?></th>
                        </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        修改用户信息
                    </h4>
                </div>
                <div class="modal-body">
                    <?php $form = ActiveForm::begin([
                        'id'     => 'user_form',
                        'action' => ['/sys-user/update-user']
                    ]); ?>
                    <!--<form action="/setting/add-depart" method="post" id="depart_form">-->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="true_name">姓名</label>
                            <input type="text" class="form-control" name="true_name" id="true_name" placeholder="姓名">
                        </div>
    
                        <div class="form-group">
                            <label for="exampleInputPassword1">选择部门</label>
                            <input type="text" style="width: 50%;" class="form-control" id="depart_name" value="" readonly="readonly">
                            <ul id="treeDemo" class="ztree ul_tree_display"></ul>
                        </div>
    
                        <div class="form-group">
                            <label for="mobile">电话</label>
                            <input type="text" style="width: 50%;" class="form-control" name="mobile" id="mobile" placeholder="电话">
                        </div>
    
                        <div class="form-group">
                            <label for="email">邮箱</label>
                            <input type="text" style="width: 50%;" name="email" id="email" class="form-control" placeholder="邮箱">
                        </div>
    
                        <div class="form-group">
                            <label for="email">性别</label>
                            <div class="radio">
                                <label>
                                    <input type="radio" name="sex" id="optionsRadios1" value="m" checked="">
                                    男
                                </label>&nbsp;&nbsp;&nbsp;
                                <label>
                                    <input type="radio" name="sex" id="optionsRadios2" value="f">
                                    女
                                </label>
                            </div>
                        </div>
    
                        <div class="form-group">
                            <label for="exampleInputEmail1">状态</label>
                            <select id="use_flg" name="use_flg" class="form-control" style="width: 50%;">
                                <option value="1">启用</option>
                                <option value="0">禁用</option>
                            </select>
                        </div>

                        <div class="form-group">
                            <label><span class="text-danger"></span>门店</label>
                            <select id="shops" name="shops[]" class="form-control selectpicker" multiple="multiple" title="请选择门店">
                                <?php foreach($shops as $value) { ?>
                                    <option value="<?= $value['ShopID']?>"><?= $value['ShopName']?></option>
                                <?php }?>
                            </select>
                        </div>
    
                        <input type="hidden" style="width: 50%;" name="id" class="form-control" id="id">
                        <input type="hidden" style="width: 50%;" name="dept_id" class="form-control" id="dept_id">
                        <input type="hidden" style="width: 50%;" name="dept_name" class="form-control" id="dept_name">
                    </div>
                    <!-- /.box-body -->
    
                    <?php ActiveForm::end(); ?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_depart">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    
    <div class="modal fade" id="user-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加用户
                    </h4>
                </div>
                <div class="modal-body">
                    <form action="/sys-user/add-user" method="post" id="user_info_form">
                        <div class="box-body">
                            <div class="form-group">
                                <label for="true_name">用户名</label>
                                <input type="text" class="form-control" name="user_name" id="user_name_other" placeholder="用户名">
                            </div>
    
                            <div class="form-group">
                                <label for="true_name">密码</label>
                                <input type="password" class="form-control" name="user_pwd" id="user_pwd" placeholder="密码">
                            </div>
    
                            <div class="form-group">
                                <label for="true_name">确认密码</label>
                                <input type="password" class="form-control" name="user_pwd_re" id="user_pwd_re" placeholder="确认密码">
                            </div>
    
                            <div class="form-group">
                                <label for="true_name">姓名</label>
                                <input type="text" class="form-control" name="true_name" id="true_name_other" placeholder="姓名">
                            </div>
    
                            <div class="form-group">
                                <label for="exampleInputPassword1">选择部门</label>
                                <input type="text" style="width: 50%;" class="form-control" id="depart_name_other" value="顶级部门" readonly="readonly">
                                <ul id="treeDemo_other" class="ztree ul_tree_display"></ul>
                            </div>
    
                            <div class="form-group">
                                <label for="mobile">电话</label>
                                <input type="text" style="width: 50%;" class="form-control" name="mobile" id="mobile_other" placeholder="电话">
                            </div>
    
                            <div class="form-group">
                                <label for="email">邮箱</label>
                                <input type="text" style="width: 50%;" name="email" id="email_other" class="form-control" placeholder="邮箱">
                            </div>
    
                            <div class="form-group">
                                <label for="email">性别</label>
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="sex" id="optionsRadios1" value="m" checked="">
                                        男
                                    </label>&nbsp;&nbsp;&nbsp;
                                    <label>
                                        <input type="radio" name="sex" id="optionsRadios2" value="f">
                                        女
                                    </label>
                                </div>
                            </div>
    
                            <div class="form-group">
                                <label for="exampleInputEmail1">状态</label>
                                <select name="use_flg" class="form-control" style="width: 50%;">
                                    <option value="1">启用</option>
                                    <option value="0">禁用</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <label><span class="text-danger"></span>门店</label>
                                <select id="shops" name="shops[]" class="form-control selectpicker" multiple="multiple" title="请选择门店">
                                    <?php foreach($shops as $value) { ?>
                                        <option value="<?= $value['ShopID']?>"><?= $value['ShopName']?></option>
                                    <?php }?>
                                </select>
                            </div>

    
                            <input type="hidden" style="width: 50%;" name="dept_id" class="form-control" id="dept_id_other">
                            <input type="hidden" style="width: 50%;" name="dept_name" class="form-control" id="dept_name_other">
                        </div>
                        <!-- /.box-body -->
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_master">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    
    <div class="modal fade" id="role-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        选择角色
                    </h4>
                </div>
                <div class="modal-body">
                    <?php $form = ActiveForm::begin([
                        'id'     => 'master_form',
                        'action' => ['/sys-user/user-mapped-role']
                    ]); ?>
                    <!--<form action="/setting/add-depart" method="post" id="depart_form">-->
                    <div class="box-body">
                        <div class="form-group">
                            <!--<label for="role_group_id">角色</label>-->
                            <div class="checkbox">
                                <?php foreach($group_list as $value){?>
                                    <div class="role_group_div">
                                        <?= $value['role_group_name']?>
                                    </div>
                                    <?php foreach($value['role_list'] as $val){?>
                                        <label>
                                            <input name="role_id[]" type="checkbox" value="<?= $val['id']?>">
                                            <?= $val['role_name']?>
                                        </label>
                                    <?php }?>
                                <?php }?>
                            </div>
                        </div>
    
                        <div class="form-group">
                            <label for="memo">备注</label>
                            <textarea class="form-control" name="memo" id="memo" rows="3" placeholder="" ></textarea>
                        </div>
                        <input type="hidden" style="width: 50%;" name="user_id" class="form-control" id="user_id">
                    </div>
                    <!-- /.box-body -->
    
                    <?php ActiveForm::end(); ?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <a type="button" class="btn btn-primary ajax_post_role">
                        提交
                    </a>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<!-- 固定js -->
<script type="text/javascript" src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="../static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../static/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../static/plugins/zTree/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="../static/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="../static/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="../static/plugins/bootstrap-select/js/bootstrap-select.js"></script>
<script type="text/javascript" src="../static/plugins/bootstrap-select/js/defaults-zh_CN.js"></script>
<script type="text/javascript" src="/static/app/global.js?version=<?=Yii::$app->params['version']?>"></script>
<script type="text/javascript" src="../static/app/sys-user/index.js?version=<?=Yii::$app->params['version']?>"></script>
<script>
    var zNodes = <?= $tree_list ?>;
</script>